<?php

include "koneksi.php";

$response = array();
  
    $id_member = $_POST['id_member'];
	$pass_lama = $_POST['pass_lama'];
	$encrypt_pass_lama = md5($pass_lama);
	$pass_baru = $_POST['pass_baru'];
	$encrypt_pass_baru = md5($pass_baru);

	$cek_pass = mysql_query("SELECT * FROM member WHERE id_member='$id_member' AND password='$encrypt_pass_lama' ");
	
	if(mysql_num_rows($cek_pass) == 1){
	
		$q = mysql_query('UPDATE member SET password ="'.$encrypt_pass_baru.'" WHERE id_member ="'.$id_member.'" ');
	
		$r = mysql_fetch_array($cek_pass);
		
		$response["hasil"] = 1;
		$response["id_member"] = $r["id_member"];
		$response["pesan"] = "Ganti Password Berhasil.";

		echo json_encode($response);
	
	}
	else{
	
		$response["hasil"] = 0;
		$response["pesan"] = "Ganti Password Gagal.";
		
		echo json_encode($response);

	}

?>